package com.sinya.shoppingmall.utils;

import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator;

import com.nineoldandroids.animation.Animator;

import animationslibrary.AnimationHelp;
import animationslibrary.Techniques;

/**
 * @author KoizumiSinya
 * @date 2015/12/30.
 */
public class AnimationUtils {

    public static void startAnim(final View animView, int time, final Techniques anim, final boolean isHide) {
        AnimationHelp.AnimationOperation rope = AnimationHelp.with(anim).duration(time)//
                .interpolate(new AccelerateDecelerateInterpolator())//
                .withListener(new Animator.AnimatorListener() {
                    @Override
                    public void onAnimationStart(Animator animator) {
                        if (!isHide) {
                            animView.setVisibility(View.VISIBLE);
                        }
                    }

                    @Override
                    public void onAnimationEnd(Animator animator) {
                        if (isHide) {
                            animView.setVisibility(View.GONE);
                        }
                    }

                    @Override
                    public void onAnimationCancel(Animator animator) {
                    }

                    @Override
                    public void onAnimationRepeat(Animator animator) {
                    }
                }).playOn(animView);
    }
}
